﻿using Todos.Application.Roles.Specs;

namespace Todos.Application.Roles.Commands;

public class DeleteRoleCommand : IRequest<ApiResult>, ICommand
{
    public required long[] Ids { get; set; }
}

public class DeleteRoleCommandHandler(IRepository<Role> repository) : IRequestHandler<DeleteRoleCommand, ApiResult>
{
    public async Task<ApiResult> Handle(DeleteRoleCommand request, CancellationToken cancellationToken)
    {
        var spec = new RoleByIdsSpec(request.Ids);
        await repository.DeleteBatchAsync(spec, cancellationToken);
        return ApiResult.Success();
    }
}
